package org.dei.perla.rockfall.gui.queryforge;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

class GainsSwitchPanel extends ReadableStatusPanel {

	private JCheckBox jCheckBox5;
	private JCheckBox jCheckBox6;
	private JCheckBox jCheckBox7;
	private JCheckBox jCheckBox8;
	private JCheckBox jCheckBox9;
	private JCheckBox jCheckBox10;
	private JCheckBox jCheckBox11;

	protected GainsSwitchPanel(String title) {
		super(title);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected int getStatus() {
		int retvalue = 0;
				
		boolean check5 = this.jCheckBox5.isSelected();
		boolean check6 = this.jCheckBox6.isSelected();
		boolean check7 = this.jCheckBox7.isSelected();
		boolean check8 = this.jCheckBox8.isSelected();
		boolean check9 = this.jCheckBox9.isSelected();
		boolean check10 = this.jCheckBox10.isSelected();
		boolean check11 = this.jCheckBox11.isSelected();
		
		
		if(check5){
			retvalue |= 0x0040;
		}
		
		if(check6){
			retvalue |= 0x0001;
		}
		
		if(check7){
			retvalue |= 0x0002;
		}
		
		if(check8){
			retvalue |= 0x0004;
		}
		
		if(check9){
			retvalue |= 0x0008;
		}
		
		if(check10){
			retvalue |= 0x0010;
		}
		
		if(check11){
			retvalue |= 0x0020;
		}
		
		return retvalue;
	}

	@Override
	protected void setStatus(int stato) {
		this.jCheckBox5.setSelected((stato & 0x0040) > 0);
		this.jCheckBox6.setSelected((stato & 0x0001) > 0);
		this.jCheckBox7.setSelected((stato & 0x0002) > 0);
		this.jCheckBox8.setSelected((stato & 0x0004) > 0);
		this.jCheckBox9.setSelected((stato & 0x0008) > 0);
		this.jCheckBox10.setSelected((stato & 0x0010) > 0);
		this.jCheckBox11.setSelected((stato & 0x0020) > 0);		
	}

	@Override
	protected void setupInternalComponents() {
		
		
		//Quinto blocco di scelte
		
		jCheckBox5 = new JCheckBox();
		jCheckBox5.setSelected(true);
		JLabel jlabel5 = new JLabel("gain switch canale CRACKMETER");
		JPanel jpanel5 = new JPanel();
		BoxLayout layout5 = new BoxLayout(jpanel5, BoxLayout.X_AXIS);
		jpanel5.add(jlabel5);
		jpanel5.add(jCheckBox5);
		
	//Quinto blocco di scelte
		
		jCheckBox6 = new JCheckBox();
		jCheckBox6.setSelected(true);
		JLabel jlabel6 = new JLabel("gain switch canale X MEMS");
		JPanel jpanel6 = new JPanel();
		BoxLayout layout6 = new BoxLayout(jpanel6, BoxLayout.X_AXIS);
		jpanel6.add(jlabel6);
		jpanel6.add(jCheckBox6);
		
	//Quinto blocco di scelte
		
		jCheckBox7 = new JCheckBox();
		jCheckBox7.setSelected(true);
		JLabel jlabel7 = new JLabel("gain switch canale Y MEMS");
		JPanel jpanel7 = new JPanel();
		BoxLayout layout7 = new BoxLayout(jpanel7, BoxLayout.X_AXIS);
		jpanel7.add(jlabel7);
		jpanel7.add(jCheckBox7);
		
	//Quinto blocco di scelte
		
		jCheckBox8 = new JCheckBox();
		jCheckBox8.setSelected(true);
		JLabel jlabel8 = new JLabel("gain switch canale Z MEMS");
		JPanel jpanel8 = new JPanel();
		BoxLayout layout8 = new BoxLayout(jpanel8, BoxLayout.X_AXIS);
		jpanel8.add(jlabel8);
		jpanel8.add(jCheckBox8);
		
	//Quinto blocco di scelte
		
		jCheckBox9 = new JCheckBox();
		jCheckBox9.setSelected(true);
		JLabel jlabel9 = new JLabel("gain switch canale X GEO ");
		JPanel jpanel9 = new JPanel();
		BoxLayout layout9 = new BoxLayout(jpanel9, BoxLayout.X_AXIS);
		jpanel9.add(jlabel9);
		jpanel9.add(jCheckBox9);
		
	//Quinto blocco di scelte
		
		jCheckBox10 = new JCheckBox();
		jCheckBox10.setSelected(true);
		JLabel jlabel10 = new JLabel("gain switch canale Y GEO ");
		JPanel jpanel10 = new JPanel();
		BoxLayout layout10 = new BoxLayout(jpanel10, BoxLayout.X_AXIS);
		jpanel10.add(jlabel10);
		jpanel10.add(jCheckBox10);
		
		
	//Quinto blocco di scelte
		
		jCheckBox11 = new JCheckBox();
		jCheckBox11.setSelected(true);
		JLabel jlabel11 = new JLabel("gain switch canale Z GEO ");
		JPanel jpanel11 = new JPanel();
		BoxLayout layout11 = new BoxLayout(jpanel11, BoxLayout.X_AXIS);
		jpanel11.add(jlabel11);
		jpanel11.add(jCheckBox11);
		
		
		
		//aggiungo tutti i blocchi
		this.add(jpanel5);
		this.add(jpanel6);
		this.add(jpanel7);
		this.add(jpanel8);
		this.add(jpanel9);
		this.add(jpanel10);
		this.add(jpanel11);
	}

}
